package edu.sjtu.grid.workflow.facts;

import edu.sjtu.grid.workflow.Util;

public class Use {

	enum LINK{
		Input,
		Output
	}
	
	private String file = null;
	private LINK link = null;
	private long size = 0;
	
	public boolean matches(Use a)
	{
		if(this.file.equals(a.getFile())
			//&& this.size == a.getSize()
			&& this.link != a.getLink())
			return true;
		else
			return false;
	}
	public String toString()
	{
		String s = "";
		s += Util.formatOutputString(""+size, 1);
		if(link == LINK.Input)
			s += "input\t";
		else
			s += "output\t";
		s += Util.formatOutputString(file, 2);
		return s;
	}
	
	public Use(String file, String link, String size)
	{
		this.file = file;
		if("input".equals(link))
			this.link = LINK.Input;
		else
			this.link = LINK.Output;
		this.size = Long.parseLong(size);
		//System.out.println(size);
		//System.out.println(this.size);
	}

	public String getFile() {
		return file;
	}

	public LINK getLink() {
		return link;
	}

	public long getSize() {
		return size;
	}
}
